//
//  SecondCell.m
//  ChooseCar
//
//  Created by Xue Senhong on 15/5/19.
//  Copyright (c) 2015年 薛森鸿. All rights reserved.
//

#import "SecondCell.h"

@implementation SecondCell
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    }
    return self;
}

- (void)sendMasterArray:(NSArray *)masterArray serialArray:(NSArray *)array
{
    UILabel *hotLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth * 10 / 375, 0, kScreenWidth * 200 / 375, kScreenHeight * 30 / 667)];
    hotLabel.text = @"热门推荐";
    
#pragma 热门推荐 品牌界面
    [self.contentView addSubview:hotLabel];
    for (int i = 0; i < masterArray.count; i++) {
        CGFloat standard = kScreenWidth / masterArray.count;
        BrandButton *brandButton = [[BrandButton alloc] initWithFrame:CGRectMake(standard * i, kScreenHeight * 30 / 667, standard, standard + 20)];
        UIImageView *masterImage = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 10 / 375, kScreenHeight * 10 / 667, standard - 20, standard - 20)];
        UILabel *masterLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth * 10 / 375, standard, standard - 20, kScreenHeight * 20 / 667)];
        
        
        SecondCellModel *model = [masterArray objectAtIndex:i];
        brandButton.brandModel = model;
        
        [brandButton addTarget:self action:@selector(sendModel:) forControlEvents:UIControlEventTouchUpInside];
        
        [masterImage sd_setImageWithURL:[NSURL URLWithString:model.pic_url] placeholderImage:nil];
        masterLabel.text = model.masterName;
        masterLabel.font = [UIFont systemFontOfSize:14];
        masterLabel.textAlignment = NSTextAlignmentCenter;
        
        [brandButton addSubview:masterLabel];
        [brandButton addSubview:masterImage];
        [self.contentView addSubview:brandButton];
        
        [model release];
        [brandButton release];
        [masterImage release];
        [masterLabel release];
    }
    
#pragma 热门推荐 车型界面
    for (int i = 0; i < 3; i++) {
        CGFloat standard = kScreenWidth / 3;
        BrandButton *serialButton = [[BrandButton alloc] initWithFrame:CGRectMake(standard * i, kScreenHeight * 130 / 667, standard, standard)];
        UIImageView *serialImage = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 10 / 375, kScreenHeight * 10 / 667, standard - 25, standard - 35)];
        
        SecondCellModel *model = [array objectAtIndex:i];
        serialButton.brandModel = model;
        [serialButton addTarget:self action:@selector(sendSerial:) forControlEvents:UIControlEventTouchUpInside];
        
        
        UILabel *serialLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth * 10 / 375, standard - 20, standard - 30, kScreenHeight * 20 / 667)];
        [serialImage sd_setImageWithURL:[NSURL URLWithString:model.pic_url] placeholderImage:nil];
        serialLabel.textAlignment = NSTextAlignmentCenter;
        serialLabel.text = model.serialName;
        serialLabel.font = [UIFont systemFontOfSize:14];
        [serialButton addSubview:serialLabel];
        [serialButton addSubview:serialImage];
        [self.contentView addSubview:serialButton];
        
        [serialButton release];
        [model release];
        [serialLabel release];
        [serialImage release];
    }
    [hotLabel release];
}


- (void)sendModel:(BrandButton *)button
{
    [self.delegate senModel:button.brandModel];
}

- (void)sendSerial:(BrandButton *)button
{
    [self.serialDelegate serialSend:button.brandModel];
}
















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
